/**
 * Created by Administrator on 14-7-4.
 */
Ext.define("yiyuan.controller.MainCtrl", {
    extend: 'Ext.app.Controller',
    config: {
        groupName: "",
        refs: {
            mainDataView: "main dataview",
            erjiview: "erjiView",
            imgshow: "erjiView img",
            erjitoolbar: "erjiView toolbar",
            //4
            erjigentview: "erjigentView",
            erjigenttoolbar: "erjigentView toolbar",
            erjigentimg: "erjigentView img",
            //5
            erjimapview: "erjimapView",
            erjimaptoolbar: "erjimapView toolbar",
            erjimapimg: "erjimapView img",
            //san
            sanview: "san"

        },
        control: {
            mainDataView: {
                itemtap: function (series, item, event, record) {
                    var that = this;
                    var si = record.data.sort_index, erjiV, erjitoolbar, erjiImg;
                    Ext.Viewport.mask({xtype: "loadmask", message: "加载中..."});
                    switch (si) {
                        case "1-1":
                            erjiV = that.getErjiview() || Ext.create("yiyuan.view.Erji"),
                                erjitoolbar = that.getErjitoolbar(),
                                erjiImg = that.getImgshow();
                            erjiImg.setSrc("resources/images/" + si + ".png");
                            //手机挂号,去报告单有三级页面
                            erjiImg.clearListeners();
                            erjiImg.setListeners({tap: function () {
                                Ext.Viewport.mask({xtype: "loadmask", message: "加载中..."});
                                var san = that.getSanview() || Ext.create("yiyuan.view.San");
                                san.down("toolbar").setTitle("分类列表");
                                san.down("img").setSrc("resources/images/login_bg.png");
                                Ext.Viewport.setActiveItem(san);
                            }});
                            break;
                        case "2-1":
                            erjiV = that.getErjiview() || Ext.create("yiyuan.view.Erji"),
                                erjitoolbar = that.getErjitoolbar(),
                                erjiImg = that.getImgshow();
                            erjiImg.setSrc("resources/images/" + si + ".png");
                            erjiImg.clearListeners();
                            break;
                        case "3-1":
                            erjiV = that.getErjiview() || Ext.create("yiyuan.view.Erji"),
                                erjitoolbar = that.getErjitoolbar(),
                                erjiImg = that.getImgshow();
                            erjiImg.setSrc("resources/images/" + si + ".png");
                            erjiImg.clearListeners();
                            erjiImg.setListeners({tap: function () {
                                Ext.Viewport.mask({xtype: "loadmask", message: "加载中..."});
                                var san = that.getSanview() || Ext.create("yiyuan.view.San");
                                san.down("toolbar").setTitle("科室介绍");
                                san.down("img").setSrc("resources/images/keshijieshao.png");
                                Ext.Viewport.setActiveItem(san);
                            }});
                            break;
                        case "4-1":
                            erjiV = that.getErjigentview() || Ext.create("yiyuan.view.Erjigent"),
                                erjitoolbar = that.getErjigenttoolbar(),
                                erjiImg = that.getErjigentimg();
                            erjiImg.setSrc("resources/images/" + si + ".png");
                            break;
                        case "5-1":
                            erjiV = that.getErjimapview() || Ext.create("yiyuan.view.Erjimap"),
                                erjitoolbar = that.getErjimaptoolbar();
                            erjiImg = that.getErjimapimg();
                            erjiImg.setSrc("resources/images/" + si + ".png");
                            break;
                        case "6-1":
                            erjiV = that.getErjiview() || Ext.create("yiyuan.view.Erji"),
                                erjitoolbar = that.getErjitoolbar(),
                                erjiImg = that.getImgshow();
                            erjiImg.setSrc("resources/images/" + si + ".png");
                            erjiImg.clearListeners();
                            erjiImg.setListeners({tap: function () {
                                Ext.Viewport.mask({xtype: "loadmask", message: "加载中..."});
                                var san = that.getSanview() || Ext.create("yiyuan.view.San");
                                san.down("toolbar").setTitle("医生列表");
                                san.down("img").setSrc("resources/images/doctor_list.png");
                                Ext.Viewport.setActiveItem(san);
                            }});
                            break;
                        case "7-1":
                            erjiV = that.getErjiview() || Ext.create("yiyuan.view.Erji"),
                                erjitoolbar = that.getErjitoolbar(),
                                erjiImg = that.getImgshow();
                            erjiImg.setSrc("resources/images/" + si + ".png");
                            erjiImg.clearListeners();
                            erjiImg.setListeners({tap: function () {
                                Ext.Viewport.mask({xtype: "loadmask", message: "加载中..."});
                                var san = that.getSanview() || Ext.create("yiyuan.view.San");
                                san.down("toolbar").setTitle("详情列表");
                                san.down("img").setSrc("resources/images/jiankang_list.png");
                                Ext.Viewport.setActiveItem(san);
                            }});
                            break;
                        case "8-1":
                            erjiV = that.getErjiview() || Ext.create("yiyuan.view.Erji"),
                                erjitoolbar = that.getErjitoolbar(),
                                erjiImg = that.getImgshow();
                            erjiImg.setSrc("resources/images/" + si + ".png");
                            erjiImg.clearListeners();
                            erjiImg.setListeners({tap: function () {
                                Ext.Viewport.mask({xtype: "loadmask", message: "加载中..."});
                                var san = that.getSanview() || Ext.create("yiyuan.view.San");
                                san.down("toolbar").setTitle("健康百科");
                                san.down("img").setSrc("resources/images/jibingku.png");
                                Ext.Viewport.setActiveItem(san);
                            }});
                            break;
                    }
                    erjitoolbar.setTitle(record.data.title);
                    Ext.Viewport.setActiveItem(erjiV);
                    setTimeout(function () {
                        Ext.Viewport.unmask();
                    }, 200)

                }
            }
        }
    }

})
